#-*- encoding:utf-8 -*-
from collections import Counter

#1. Hash 26个小写字母 统计每个字母出现次数 
#2. 循环遍历 耗时
def conConstract(ransomNote,magazine):
	if ransomNote == "":
		return True
	else:
		if magazine == "":
			return False
	rCnt = Counter(ransomNote)
	mCnt = Counter(magazine)
	for x in rCnt:
		if mCnt.has_key(x) is False or mCnt[x] < rCnt[x]:
			return False
	return True

s1 = "fihjjjjei"
s2 = "hjibagacbhadfaefdjaeaebgi"
print conConstract(s1,s2)


# 思路对，但python中无char类型，java可以
# def conConstract(ransomNote,magazine):
# 	rList = [0]*26
# 	mList = [0]*26
# 	for x in ransomNote:
# 		rList[x-'a'] +=1
# 	for x in magazine:
# 		mList[x-'a'] +=1

# 	for i in xrange(26):
# 		if mList[i]-rList[i] < 0:
# 			return False
# 	return True